Imports VBexamples.tamsSC
Public Class Example2
    Sub example2()
        Dim handle1, handle2 As IntPtr

        ' The "tamsSCusb1" and "tamsSCusb2" strings MUST match the identifiers
        ' shown in the title bar of the Graphical User Interface.
        ' See "Using more than one TAMS 1887 in a System" in the
        ' Installation and Operation Manual.

        handle1 = tamsSCstart("tamsSCusb1")
        If INVALID_HANDLE_VALUE = handle1.ToInt32 Then
            MsgBox(tamsSCerror(), MsgBoxStyle.OKOnly, "Error")
            Exit Sub
        End If

        handle2 = tamsSCstart("tamsSCusb2")
        If INVALID_HANDLE_VALUE = handle2.ToInt32 Then
            MsgBox(tamsSCerror(), MsgBoxStyle.OKOnly, "Error")
            Exit Sub
        End If

        ' Now set switch 4 of each controller to position 2.

        If FAIL = tamsSCswitch(handle1, SWITCH_4, POSITION_2) Then
            MsgBox(tamsSCerror(), MsgBoxStyle.OKOnly, "Error")
            Exit Sub
        End If

        If FAIL = tamsSCswitch(handle2, SWITCH_4, POSITION_2) Then
            MsgBox(tamsSCerror(), MsgBoxStyle.OKOnly, "Error")
            Exit Sub
        End If

        tamsSCend(handle1)
        tamsSCend(handle2)
    End Sub
End Class

